VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsHistClientes"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False

Option Explicit
Dim vSQL As String

Public pNumError As Long
Public pDesError As String
Public pCanReg As Long
Public pRS As ADODB.Recordset
Public pIdDevuelto As Long

Private vIdHistCliente As Long

Public Property Let IdHistCliente(ByVal VData As Long)
    vIdHistCliente = VData
End Property
Public Property Get IdHistCliente() As Long
    IdHistCliente = vIdHistCliente
End Property

Private Sub AsignarValores(Optional ByVal rs As ADODB.Recordset, Optional pNoAsigRs As Boolean)
    If Not pNoAsigRs Then
        Set Me.pRS = rs
    End If
    Me.pCanReg = objCnxAeros.pCanReg
    Me.pDesError = objCnxAeros.pDesError
    Me.pIdDevuelto = objCnxAeros.pUltIdenOtor
    Me.pNumError = objCnxAeros.pNumError
End Sub


Public Function insertar_historia(ByVal id_cliente As Long, _
                                    ByVal fecha As Date, ByVal detalle As String) As Boolean
Dim vSQL As String
  
    vSQL = " INSERT INTO historia_clientes (id_cliente, fecha, detalle) " & _
           " VALUES (" & id_cliente & ",'" & fecha & "','" & detalle & "')"
    If objCnxAeros.EjecutarComando(vSQL) Then
        insertar_historia = True
    Else
        insertar_historia = False
    End If
    AsignarValores , True
 
End Function

Public Function borrar_historia(ByVal id_historia As Long) As Boolean
Dim vSQL As String
  
    vSQL = " delete from historia_clientes where id_historia = " & id_historia
    If objCnxAeros.EjecutarComando(vSQL) Then
        borrar_historia = True
    Else
        borrar_historia = False
    End If

End Function

Public Sub sel_historias(ByVal desde_date1 As Date, ByVal hasta_date2 As Date)
Dim strSQL As String
Dim rs As New ADODB.Recordset

    strSQL = " SELECT a.id_historia, " & _
             " From historia_clientes " & _
             "   WHERE fecha between #" & desde_date1 & "# And #" & hasta_date2 & "#"
             
                
    Set rs = objCnxAeros.EjecutarConsulta(strSQL)
    AsignarValores rs

End Sub

Public Sub sel_detalles(ByVal id_cliente As Long)
Dim strSQL As String
Dim rs As New ADODB.Recordset

    strSQL = " SELECT id_historia,fecha,detalle " & _
             " From historia_clientes " & _
             "   WHERE id_cliente = " & id_cliente & " ORDER BY fecha desc"
             
                
    Set rs = objCnxAeros.EjecutarConsulta(strSQL)
    AsignarValores rs

End Sub

Public Sub sel_Historia(ByVal id As Long)
Dim strSQL As String
Dim rs As New ADODB.Recordset

    strSQL = " SELECT h.id_historia,h.fecha,h.detalle, c.id_cliente " & _
             " From historia_clientes h, clientes c " & _
             " WHERE h.id_cliente = c.id_cliente and id_historia = " & id
             
                
    Set rs = objCnxAeros.EjecutarConsulta(strSQL)
    AsignarValores rs

End Sub
